using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace DungeonOfDespair
{
    public class GameStateOver
        : GameState
    {
        private GameStateType m_gameStateTypeNext;
        private int m_iFade;

        public GameStateOver()
        {
            m_gameStateTypeNext = GameStateType.None;
            m_iFade = 25;
        }

        public void OnKeyDown(object objectSender, KeyEventArgs keyEventArgs)
        {
        }

        public void OnKeyUp(object objectSender, KeyEventArgs keyEventArgs)
        {
            switch (keyEventArgs.KeyCode)
            {
                case Keys.Space:
                case Keys.Return:
                case Keys.Escape:
                    m_gameStateTypeNext = GameStateType.Title;
                    break;
            }
        }

        public void Update()
        {
            if (m_iFade > 0) --m_iFade;
        }

        public void Draw(Graphics graphics)
        {
            Image imageGameOver = Properties.Resources.GameOver;
            graphics.DrawImage(imageGameOver, 0, 0, imageGameOver.Width, imageGameOver.Height);

            graphics.FillRectangle(new SolidBrush(Color.FromArgb(m_iFade * 255 / 25, 0, 0, 0)),
                0, 0, 640, 480);
        }

        public GameStateType NextState
        {
            get { return m_gameStateTypeNext; }
        }
    }
}
